<?php
/*
cmfit
Copyright (C) 2000-2007 Andreas Bengtsson

Email: anteman@users.sourceforge.net

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

// Andreas Bengtsson 2000-05-29
//
// newbbs.php a bounce page to create new bbs files
//
// -------------------------------------------------------------
// post or get variables;
// filename
// currdir


$newname=$_GET['newname'];
$currdir=$_GET['currdir'];
$bbstemplate=$_GET['bbstemplate'];


require('functions.php');
require('config.php');

print("<BR>\n");
print("--------".$newname."-------------<BR>\n");
print("--------".rawurldecode($currdir)."-------------<BR>\n");
print("--------".rawurldecode($bbstemplate)."-------------<BR>\n");

// Append .html if not included...
if(substr($newname,strlen($newname)-5) != ".html"){
  $newname=$newname.".html";
}

if(file_exists($c_templatedir.rawurldecode($currdir).$newname)){
	if(!isset($overwriteconfirmed)){
		print"File exists '".$c_templatedir.rawurldecode($currdir).$newname."'.<BR>\n";
		print"<A HREF=\"newbbs.php?newname=".$newname."&currdir=".$currdir."&bbstemplate=".$bbstemplate."&overwriteconfirmed=1\">[Ok, overwrite!]</A>&nbsp;<A HREF=\"javascript:history(-1)\">[Cancel]</A><BR>\n";
		return;
	}
}

// Clone template file
if ( !copy(rawurldecode($bbstemplate), $c_templatedir.rawurldecode($currdir).$newname) ) {
  print("failed to copy $file...<br>\n");
}

// redirect to edit page
print "<A HREF=\"editor.php?filename=".urlencode($newname)."&currdir=".urlencode($currdir)."\">".$newname."</A><BR>\n";


?>

